<!DOCTYPE html>












  


<html class="theme-next muse use-motion" lang="zh-CN">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2"/>
<meta name="theme-color" content="#222">












<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />






















<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=6.3.0" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=6.3.0">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=6.3.0">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=6.3.0">


  <link rel="mask-icon" href="/images/logo.svg?v=6.3.0" color="#222">









<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    version: '6.3.0',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: false,
    fastclick: false,
    lazyload: false,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>


  




  <meta name="description" content="MySQL的安装下载MySQL使用百度搜索关键字“MySQL 官网”  或者直接打开网址：https://www.mysql.com/">
<meta name="keywords" content="MySQL">
<meta property="og:type" content="article">
<meta property="og:title" content="WINDOWS平台下MySQL的安装和配置">
<meta property="og:url" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/index.html">
<meta property="og:site_name" content="黄亚龙的技术博客">
<meta property="og:description" content="MySQL的安装下载MySQL使用百度搜索关键字“MySQL 官网”  或者直接打开网址：https://www.mysql.com/">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/1.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/2.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/3.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/4.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/5.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/6.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/7.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/8.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/9.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/10.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/11.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/12.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/13.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/14.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/15.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/16.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/17.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/18.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/19.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/20.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/21.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/22.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/23.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/24.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/25.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/23.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/26.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/27.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/25.png">
<meta property="og:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/28.png">
<meta property="og:updated_time" content="2018-05-25T05:52:20.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="WINDOWS平台下MySQL的安装和配置">
<meta name="twitter:description" content="MySQL的安装下载MySQL使用百度搜索关键字“MySQL 官网”  或者直接打开网址：https://www.mysql.com/">
<meta name="twitter:image" content="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/1.png">






  <link rel="canonical" href="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/"/>



<script type="text/javascript" id="page.configurations">
  CONFIG.page = {
    sidebar: "",
  };
</script>

  <title>WINDOWS平台下MySQL的安装和配置 | 黄亚龙的技术博客</title>
  









  <noscript>
  <style type="text/css">
    .use-motion .motion-element,
    .use-motion .brand,
    .use-motion .menu-item,
    .sidebar-inner,
    .use-motion .post-block,
    .use-motion .pagination,
    .use-motion .comments,
    .use-motion .post-header,
    .use-motion .post-body,
    .use-motion .collection-title { opacity: initial; }

    .use-motion .logo,
    .use-motion .site-title,
    .use-motion .site-subtitle {
      opacity: initial;
      top: initial;
    }

    .use-motion {
      .logo-line-before i { left: initial; }
      .logo-line-after i { right: initial; }
    }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">黄亚龙的技术博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
    
      
        <p class="site-subtitle">会打代码的哈士奇为您服务</p>
      
    
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>



<nav class="site-nav">
  
    <ul id="menu" class="menu">
      
        
        
        
          
          <li class="menu-item menu-item-home">
    <a href="/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-home"></i> <br />首页</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-tags">
    <a href="/tags/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />标签</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-categories">
    <a href="/categories/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-th"></i> <br />分类</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-archives">
    <a href="/archives/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />归档</a>
  </li>

      
      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />搜索</a>
        </li>
      
    </ul>
  

  
    

  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off"
             placeholder="搜索..." spellcheck="false"
             type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



  



</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://huang6349.github.io/2018/05/25/WINDOWS平台下MySQL的安装和配置/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="黄亚龙">
      <meta itemprop="description" content="黄亚龙的技术博客">
      <meta itemprop="image" content="/images/avatar.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="黄亚龙的技术博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">WINDOWS平台下MySQL的安装和配置
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2018-05-25 13:10:06 / 修改时间：13:52:20" itemprop="dateCreated datePublished" datetime="2018-05-25T13:10:06+08:00">2018-05-25</time>
            

            
              

              
            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/数据库/" itemprop="url" rel="index"><span itemprop="name">数据库</span></a></span>

                
                
              
            </span>
          

          
            
          

          
          

          
            <span class="post-meta-divider">|</span>
            <span class="post-meta-item-icon"
            >
            <i class="fa fa-eye"></i>
             阅读次数： 
            <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>
            </span>
          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="MySQL的安装"><a href="#MySQL的安装" class="headerlink" title="MySQL的安装"></a>MySQL的安装</h2><h3 id="下载MySQL"><a href="#下载MySQL" class="headerlink" title="下载MySQL"></a>下载MySQL</h3><p>使用百度搜索关键字“MySQL 官网”</p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/1.png" alt="MySQL"></p>
<p>或者直接打开网址：<a href="https://www.mysql.com/" target="_blank" rel="noopener">https://www.mysql.com/</a></p>
<a id="more"></a>
<p>选择<code>Downloads &gt; Community &gt; MySQL Community Server</code>打开下载界面</p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/2.png" alt="MySQL"></p>
<p>选择5.6的版本，因为5.7的安装比较坑</p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/3.png" alt="MySQL"></p>
<p>选择对应的平台，进行下载</p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/4.png" alt="MySQL"></p>
<p>点击下载后，这里会看到一个准备开始下载的界面，点击<code>No thanks, just start my download.</code>就可以开始下载MySQL了</p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/5.png" alt="MySQL"></p>
<p>当前最新GA版下载地址：<a href="https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.37-winx64.zip" target="_blank" rel="noopener">v5.6.37</a></p>
<h3 id="安装MySQL"><a href="#安装MySQL" class="headerlink" title="安装MySQL"></a>安装MySQL</h3><p>等待下载完成（由于时间关系，我就使用已经下载过的v5.6.31进行演示），将下载的压缩包解压，例如我将压缩包解压到“D盘”</p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/6.png" alt="MySQL"></p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/7.png" alt="MySQL"></p>
<h2 id="配置环境变量"><a href="#配置环境变量" class="headerlink" title="配置环境变量"></a>配置环境变量</h2><p>右键单击我的电脑，选择属性，打开系统设置</p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/8.png" alt="MySQL"></p>
<p>打开高级系统设置</p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/9.png" alt="MySQL"></p>
<p>打开环境变量配置</p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/10.png" alt="MySQL"></p>
<p>新建变量名“MYSQL_HOME”，变量值为MySQL解压后的根路径<br>例如：<br>变量名：<code>MYSQL_HOME</code><br>变量值：<code>D:\mysql-5.6.31-winx64</code></p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/11.png" alt="MySQL"></p>
<p>将MYSQL_HOME配置到Path中</p>
<p>例如：<code>%MYSQL_HOME%\bin</code>（注意，Path变量值如果是在最后，则不用“<code>;</code>”）</p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/12.png" alt="MySQL"></p>
<h2 id="配置MySQL"><a href="#配置MySQL" class="headerlink" title="配置MySQL"></a>配置MySQL</h2><p>编辑MySQL根目录下的<code>my-default.ini</code>文件</p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/13.png" alt="MySQL"></p>
<figure class="highlight ini"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># For advice on how to change settings please see</span></span><br><span class="line"><span class="comment"># http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html</span></span><br><span class="line"><span class="comment"># *** DO NOT EDIT THIS FILE. It's a template which will be copied to the</span></span><br><span class="line"><span class="comment"># *** default location during install, and will be replaced if you</span></span><br><span class="line"><span class="comment"># *** upgrade to a newer version of MySQL.</span></span><br><span class="line"><span class="section">[mysql]</span></span><br><span class="line"><span class="comment"># 设置客户端默认字符集</span></span><br><span class="line"><span class="attr">default-character-set</span> = utf8 </span><br><span class="line"></span><br><span class="line"><span class="section">[mysqld]</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># Remove leading # and set to the amount of RAM for the most important data</span></span><br><span class="line"><span class="comment"># cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.</span></span><br><span class="line"><span class="comment"># innodb_buffer_pool_size = 128M</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># Remove leading # to turn on a very important data integrity option: logging</span></span><br><span class="line"><span class="comment"># changes to the binary log between backups.</span></span><br><span class="line"><span class="comment"># log_bin</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># These are commonly set, remove the # and set as required.</span></span><br><span class="line"><span class="comment"># basedir = .....</span></span><br><span class="line"><span class="comment"># datadir = .....</span></span><br><span class="line"><span class="comment"># port = .....</span></span><br><span class="line"><span class="comment"># server_id = .....</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 设置服务端字符集</span></span><br><span class="line"><span class="attr">character-set-server</span> = utf8</span><br><span class="line"><span class="comment"># 设置安装目录</span></span><br><span class="line"><span class="attr">basedir</span> = %MYSQL_HOME%</span><br><span class="line"><span class="comment"># 设置数据存放目录</span></span><br><span class="line"><span class="attr">datadir</span> = %MYSQL_HOME%\data</span><br><span class="line"><span class="comment"># 设置3306端口</span></span><br><span class="line"><span class="attr">port</span> = <span class="number">3306</span> </span><br><span class="line"></span><br><span class="line"><span class="comment"># Remove leading # to set options mainly useful for reporting servers.</span></span><br><span class="line"><span class="comment"># The server defaults are faster for transactions and fast SELECTs.</span></span><br><span class="line"><span class="comment"># Adjust sizes as needed, experiment to find the optimal values.</span></span><br><span class="line"><span class="comment"># join_buffer_size = 128M</span></span><br><span class="line"><span class="comment"># sort_buffer_size = 2M</span></span><br><span class="line"><span class="comment"># read_rnd_buffer_size = 2M </span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 设置数据模式</span></span><br><span class="line"><span class="attr">sql_mode</span>=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES</span><br></pre></td></tr></table></figure>
<h2 id="初始化MySQL"><a href="#初始化MySQL" class="headerlink" title="初始化MySQL"></a>初始化MySQL</h2><p>打开拥有管理员权限的终端</p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/14.png" alt="MySQL"></p>
<p>切换到MySQL的bin目录下</p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/15.png" alt="MySQL"></p>
<p>执行命令<code>mysqld --install</code>，看见<code>Service successfully installed.</code>代表MySQL初始化成功，否则初始化不成功</p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/16.png" alt="MySQL"></p>
<h2 id="卸载MySQL"><a href="#卸载MySQL" class="headerlink" title="卸载MySQL"></a>卸载MySQL</h2><p>首先需要停止MySQL服务（如何停止MySQL的服务下面会将），然后打开拥有管理员权限的终端，切换到MySQL的bin目录下</p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/17.png" alt="MySQL"></p>
<p>执行命令<code>mysqld --remove</code>，看见<code>Service successfully removed.</code>代表MySQL卸载成功，否则卸载不成功</p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/18.png" alt="MySQL"></p>
<h2 id="启动MySQL"><a href="#启动MySQL" class="headerlink" title="启动MySQL"></a>启动MySQL</h2><p>使用<code>Win+R</code>键，打开运行界面，输入<code>cmd</code>，打开终端，输入<code>net start mysql</code>，看见“MySQL 服务启动成功时”，就代表MySQL服务启动成功了</p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/19.png" alt="MySQL"></p>
<h2 id="停止MySQL"><a href="#停止MySQL" class="headerlink" title="停止MySQL"></a>停止MySQL</h2><p>使用<code>Win+R</code>键，打开运行界面，输入<code>cmd</code>，打开终端，输入<code>net stop mysql</code>，看见“MySQL 服务已成功停止”时，就代表MySQL服务停止成功了</p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/20.png" alt="MySQL"></p>
<h2 id="使用小技巧"><a href="#使用小技巧" class="headerlink" title="使用小技巧"></a>使用小技巧</h2><h3 id="登录MySQL"><a href="#登录MySQL" class="headerlink" title="登录MySQL"></a>登录MySQL</h3><p>使用Win+R键，打开运行界面，输入cmd，打开终端，输入<code>mysql -u 你的用户名 -p</code>，MySQL的默认用户是root，密码为空<br>例如：<code>mysql -u root -p</code></p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/21.png" alt="MySQL"></p>
<p>输入密码，若密码为空，直接回车即可</p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/22.png" alt="MySQL"></p>
<h3 id="修改root用户的密码"><a href="#修改root用户的密码" class="headerlink" title="修改root用户的密码"></a>修改root用户的密码</h3><p>使用root用户登录后，使用<code>use mysql;</code>命令切换到mysql数据库</p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/23.png" alt="MySQL"></p>
<p>使用命令行<code>update user set password=password(&#39;你的密码&#39;) where user=&#39;root&#39;;</code>来修改root用户的密码<br>例如：<code>update user set password=password(&#39;1&#39;) where user=&#39;root&#39;;</code></p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/24.png" alt="MySQL"></p>
<p>使用命令行<code>flush privileges;</code>使新配置的用户信息立即生效</p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/25.png" alt="MySQL"></p>
<h3 id="允许任何IP访问MySQL的root用户"><a href="#允许任何IP访问MySQL的root用户" class="headerlink" title="允许任何IP访问MySQL的root用户"></a>允许任何IP访问MySQL的root用户</h3><p>使用root用户登录后，使用<code>use mysql;</code>命令切换到mysql数据库</p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/23.png" alt="MySQL"></p>
<p>使用命令行<code>select user,host from user;</code>查询root用户的访问权限</p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/26.png" alt="MySQL"></p>
<p>使用命令行<code>grant all privileges on *.* to &#39;需要设置的用户&#39;@&#39;允许访问的IP&#39; identified by &#39;访问的密码&#39; with grant option;</code>为MySQL增加一行访问权限<br>例如：<code>grant all privileges on *.* to &#39;root&#39;@&#39;%&#39; identified by &#39;1&#39; with grant option;</code>IP设置成<code>%</code>的意思是允许任何IP的访问</p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/27.png" alt="MySQL"></p>
<p>使用命令行<code>flush privileges;</code>使新配置的权限立即生效</p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/25.png" alt="MySQL"></p>
<p>再次查询root用户的权限，这次已经多了一个<code>%</code>的权限了</p>
<p><img src="/2018/05/25/WINDOWS平台下MySQL的安装和配置/28.png" alt="MySQL"></p>
<p>-EOF-</p>

      
    </div>

    

    
    
    

    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div>坚持原创技术分享，您的支持将鼓励我继续创作！</div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="/images/alipay.png" alt="黄亚龙 支付宝"/>
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/MySQL/" rel="tag"># MySQL</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2018/05/25/WINDOWS平台下IDEA的安装和配置/" rel="next" title="WINDOWS平台下IDEA的安装和配置">
                <i class="fa fa-chevron-left"></i> WINDOWS平台下IDEA的安装和配置
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2018/05/25/WINDOWS平台下CMDER的安装和配置/" rel="prev" title="WINDOWS平台下CMDER的安装和配置">
                WINDOWS平台下CMDER的安装和配置 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          

  
    <div class="comments" id="comments">
      <div id="lv-container" data-id="city" data-uid="MTAyMC8zNjgwMi8xMzMzOA=="></div>
    </div>

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/images/avatar.png"
                alt="黄亚龙" />
            
              <p class="site-author-name" itemprop="name">黄亚龙</p>
              <p class="site-description motion-element" itemprop="description">黄亚龙的技术博客</p>
          </div>

          
            <nav class="site-state motion-element">
              
                <div class="site-state-item site-state-posts">
                
                  <a href="/archives/">
                
                    <span class="site-state-item-count">7</span>
                    <span class="site-state-item-name">日志</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-categories">
                  <a href="/categories/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">4</span>
                    <span class="site-state-item-name">分类</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-tags">
                  <a href="/tags/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">6</span>
                    <span class="site-state-item-name">标签</span>
                  </a>
                </div>
              
            </nav>
          

          

          
            <div class="links-of-author motion-element">
              
                <span class="links-of-author-item">
                  <a href="https://github.com/huang6349" target="_blank" title="GitHub"><i class="fa fa-fw fa-github"></i>GitHub</a>
                  
                </span>
              
                <span class="links-of-author-item">
                  <a href="mailto:252683858@qq.com" target="_blank" title="E-Mail"><i class="fa fa-fw fa-envelope"></i>E-Mail</a>
                  
                </span>
              
            </div>
          

          
          

          
          

          
            
          
          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#MySQL的安装"><span class="nav-number">1.</span> <span class="nav-text">MySQL的安装</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#下载MySQL"><span class="nav-number">1.1.</span> <span class="nav-text">下载MySQL</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#安装MySQL"><span class="nav-number">1.2.</span> <span class="nav-text">安装MySQL</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#配置环境变量"><span class="nav-number">2.</span> <span class="nav-text">配置环境变量</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#配置MySQL"><span class="nav-number">3.</span> <span class="nav-text">配置MySQL</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#初始化MySQL"><span class="nav-number">4.</span> <span class="nav-text">初始化MySQL</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#卸载MySQL"><span class="nav-number">5.</span> <span class="nav-text">卸载MySQL</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#启动MySQL"><span class="nav-number">6.</span> <span class="nav-text">启动MySQL</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#停止MySQL"><span class="nav-number">7.</span> <span class="nav-text">停止MySQL</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#使用小技巧"><span class="nav-number">8.</span> <span class="nav-text">使用小技巧</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#登录MySQL"><span class="nav-number">8.1.</span> <span class="nav-text">登录MySQL</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#修改root用户的密码"><span class="nav-number">8.2.</span> <span class="nav-text">修改root用户的密码</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#允许任何IP访问MySQL的root用户"><span class="nav-number">8.3.</span> <span class="nav-text">允许任何IP访问MySQL的root用户</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">黄亚龙</span>

  

  
</div>




  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动 v3.7.1</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/theme-next/hexo-theme-next">NexT.Muse</a> v6.3.0</div>




        
<div class="busuanzi-count">
  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv" title="总访客量">
      <i class="fa fa-user"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
    </span>
  

  
    <span class="site-pv" title="总访问量">
      <i class="fa fa-eye"></i>
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
    </span>
  
</div>









        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>


























  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=6.3.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=6.3.0"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=6.3.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=6.3.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=6.3.0"></script>



  



	





  





  
    <script type="text/javascript">
      (function(d, s) {
        var j, e = d.getElementsByTagName(s)[0];
        if (typeof LivereTower === 'function') { return; }
        j = d.createElement(s);
        j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
        j.async = true;
        e.parentNode.insertBefore(j, e);
      })(document, 'script');
    </script>
  










  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  

  

  

  
  

  

  

  

  

  

</body>
</html>
